
#include "model/PairNode.h"

namespace zeroplus::mq
{
    bool PairNode::Send(const Bytes &message)
    {
        if (message.to_string() == Status::ToString(NO_REPLY))
        {
            return false;
        }
        zmqpp::message_t zmqMessage;
        zmqMessage << message.to_string();
        auto size = conn_->WriteMsg(zmqMessage);
        return size;
    }

    Bytes PairNode::Recv()
    {
        auto [zmqMessage, res] = conn_->ReadMsg();
        std::string message;
        zmqMessage >> message;
        return Bytes::from_string(message);
    }
}
